/**
 * 
 */
package com.wolfpire.workflow.dao;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import com.wolfpire.system.common.Page;
import com.wolfpire.system.common.base.dao.IBaseHibernateDao;
import com.wolfpire.system.model.Role;
import com.wolfpire.workflow.om.MyTask;

/**
 * @author lihd
 *
 */
public interface MyTaskDao extends IBaseHibernateDao<MyTask, Long> {
	
	/**
	 *  根据流程实例ID查询任务列表 
	 * @param instanceId 流程实例ID
	 * @return
	 */
	public List<MyTask> queryProcessTaskList(Long instanceId);
	
	/**
	 * 查询流程审核详情
	 * @param instanceId
	 * @return
	 */
	public List<Map<String, Object>> queryTaskList(final Long instanceId);
	
	public List<Map<String, Object>> getBackTaskList(Long instanceId,String operateType);
	
	/**
	 * 查询驳回任务
	 * @param instanceId
	 * @return
	 */
	public MyTask getBackTask(Long instanceId);
	
	
	/**
	 * 查询会签任务历史列表
	 * @param instanceId
	 * @return
	 */
	public List<MyTask> querySignTaskList(Long instanceId);
	
	/**
	 * 按formTypeId查询待办信息
	 * @param orgId
	 * @param postId
	 * @param funId
	 * @param roleList
	 * @param userId
	 * @param formTypeId
	 * @return
	 */
	public List<Map<String, Object>> queryMyTaskList(Long orgId, Long postId, Long funId, List<Role> roleList, Long userId,String formTypeId);
	
	/**
	 * 待办数
	 * @param orgId
	 * @param postId
	 * @param funId
	 * @param roleList
	 * @param userId
	 * @return
	 */
	public int queryMyTaskCountNum(Long orgId, Long postId, Long funId, List<Role> roleList, Long userId ,String formTypeId);


	/**
	 * 构造待办SQL
	 * @param orgId
	 * @param postId
	 * @param roleList
	 * @param userId
	 * @param formTypeId
	 * @return
	 */
	public StringBuffer buildTaskSql(Long orgId, Long postId,
			List<Role> roleList, Long userId,Integer formTypeId);

	
	/**
	 * 构造任务数据SQL
	 * @param orgId
	 * @param postId
	 * @param funId
	 * @param roleList
	 * @param userId
	 * @param eventTable
	 * @param formTypeId
	 * @return
	 */
	public StringBuffer buildTaskCountSql(Long orgId, Long postId,
			List<Role> roleList, Long userId,String formTypeId);
	
	public List<Map<String, Object>> queryMyTaskListAndEvent(Long orgId, Long postId, Long funId, List<Role> roleList, Long userId ,String eventTable,String formTypeId);
	
	/**
	 * 我的待办关联催办记录置顶显示
	 * @param orgId
	 * @param postId
	 * @param funId
	 * @param roleList
	 * @param userId
	 * @param eventTable
	 * @param formTypeId
	 * @return
	 */
	public List<Map<String, Object>> queryMyTaskListAndEventByRemind(Long orgId, Long postId, Long funId, List<Role> roleList, Long userId ,String eventTable,String formTypeId);
	
	/**不支持有会签节点
	 * 根据instanceId获取jbpm关联数据
	 * @param instanceId
	 * @return
	 */
	public List<Map<String, Object>> queryMyTaskByInstanceId( Long instanceId);

	/**只支持会签节点
	 * 根据instanceId获取jbpm关联数据
	 * @param instanceId
	 * @return
	 */
	public List<Map<String, Object>> queryMyTaskByInstanceIdForSign(Long instanceId);

	public Map<String, Object> queryWfInstanceByformId(String formTypeId,
			String formId);
	
	public Map<String, Object> queryProInstance(Long workFlowId, String formId);

	public MyTask getMyTask(String instanceId, String taskName);

	
	public Map<String, Object> queryMyTask(String instanceId, String taskName);

	/**
	 * 根据实例查当前的任务
	 * @param instanceId
	 * @return
	 */
	public List<Map<String, Object>> queryActTaskByInstanceId(Long instanceId);
	
	public int getAfterTaskCountByTaskName(String taskName,Long instanceId,Long taskId);
	
	public List<MyTask> queryHistoryTaskList(Long userId);
	
	public void modifyTaskWarn(String taskId);
	
	public void modifyTaskTimeout(String taskId);
	public void modifyTaskAlert(String taskId);
	
	public int countTaskByTimeout(String timeout);
	public List<Map<String, Object>> queryTaskListByTimeout();
	
	public List<Map<String, Object>> getTaskByTaskId(Long taskId);
	
	public MyTask queryLastTaskInfo(Long instanceId);
	
	public List<Map<String, Object>> queryMyTaskBeforeCur(Long instanceId,Long taskId);
	public List<Map<String, Object>> queryMyTaskPerson(Long instanceId,String taskName);
	public List<Map<String, Object>> queryFile(Long instanceId);
	
	public int getParticipationCountByTaskId(String taskId, String userId);

	public Map<String, Object> getDemandTestInfo(String formId);

	public Map<String, Object> getBugsTestInfo(String formId);
	
	public List<BigDecimal> queryTaskIdByFormIdAndName(String formIds, String taskName);
	
	public Long getNextSequence();

	public Page<MyTask> findMyTasks(Page<MyTask> page, Long instanceId);

	public MyTask findFirstTaskInfo(Long instanceId);
}
